        /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.ifrn.utineo.web;

import br.edu.ifrn.utineo.jdbc.Conexao;
import br.edu.ifrn.utineo.modelo.Funcionario;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Raul
 */
public class CadastrarUsuarioServlet extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
        } finally { 
            out.close();
        }
    } 

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    } 

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        Funcionario med = new Funcionario();

        med.setNome(request.getParameter("usuario"));
        med.setSenha(request.getParameter("senha"));
        med.setCodigoFuncionario(Integer.parseInt(request.getParameter("CodTipoFunc")));
        med.setID(Integer.parseInt(request.getParameter("ID") ) );

        
        

        try {
            Conexao cnx = new Conexao();
            cnx.adiciona(med);
            response.sendRedirect("../administrador/cadastrar_usuario.jsp");
        } catch (SQLException ex) {
            Logger.getLogger(CadastrarUsuarioServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
